<template>
  <div>
    <div class="modal">
      <div class="modal-bg" @click="PostClose"></div>
      <div class="post">
        <!--<div class="rele-titles">员工调岗<span @click="PostClose">X</span></div>-->
        <div class="rele-titles"><span>员工调岗</span><img @click="PostClose" src="../assets/img/tub.png" alt=""></div>
        <ul class="post-list">
          <li>
            <div class="post-l-li">
              <div class="li-title_box">调职务</div>
              <div class="li-input_box">原职务
                <input readonly type="" name="" v-model="this.items.job" style="width:58%;border: 1px solid #a0a0a0;  padding-left: 10px;">
              </div>
            </div>
            <div class="post-l-li">
              <div class="li-title_box ">现职务</div>
              <div class="li-input_box">
                <select v-model="Sjob" placeholder="请选择" style="width:70%;border: 1px solid #a0a0a0;height: 28px;">
                  <option
                    v-for="item in Job"
                    :key="item.id"
                    :label="item.title"
                    :value="item.id">
                  </option>
                </select>
              </div>
            </div>
            <div class="post-title">
              员工
              <input type="text" name="" v-model="this.items.name" style="width: 17.5%; border: 1px solid #a0a0a0; padding-left: 10px;">
            </div>
            <div class="button_box">
              <el-button  @click="upsubmit" type="primary" style="line-height: 8px;">保存</el-button>
            </div>
          </li>
          <!--<li>-->
          <!--<div class="post-l-li">-->
          <!--<div class="li-title">降级</div>-->
          <!--<div class="li-input">原职务<input readonly type="" name="" v-model="this.items.job"></div>-->
          <!--</div>-->
          <!--<div class="post-l-li">-->
          <!--<div class="li-title li-title1">现职务</div>-->
          <!--<div class="li-input">-->
          <!--<el-select v-model="Jjob" placeholder="请选择" style="width:90%">-->
          <!--<el-option-->
          <!--v-for="item in Job"-->
          <!--:key="item.id"-->
          <!--:label="item.title"-->
          <!--:value="item.id">-->
          <!--</el-option>-->
          <!--</el-select>-->
          <!--<button @click="downsubmit">保存</button>-->
          <!--</div>-->
          <!--</div>-->
          <!--</li>-->
        </ul>
        <ul class="post-list post-list1">
          <li>
            <div class="post-l-li">
              <div class="title">原部门</div>
              <div class="li-title"></div>
              <div class="li-input">区域
                <input readonly type="text" name="" v-model="this.items.department" style="width: 65%;border: 1px solid #a0a0a0; padding-left: 10px;">
              </div>
            </div>
            <div class="post-l-li">
              <div class="title">现部门</div>
              <div class="li-title"></div>
              <div class="li-input">区域
                <select @change="getMen" v-model="department_id" placeholder="请选择" style="width:75%;border: 1px solid #a0a0a0;height: 28px;">
                  <option
                    v-for="item in Quyu"
                    :key="item.id"
                    :label="item.title"
                    :value="item.id">
                  </option>
                </select>
              </div>
            </div>
          </li>
          <li>
            <div class="post-l-li">
              <div class="li-title">调部门</div>
              <div class="li-input">门店
                <input readonly type="text" name="" v-model="this.items.store" style="width: 65%;border: 1px solid #a0a0a0; padding-left: 10px;">
              </div>
            </div>
            <div class="post-l-li">
              <div class="li-title"></div>
              <div class="li-input">门店
                <select @change="getGroup" v-model="store_id" placeholder="请选择" style="width:75%;border: 1px solid #a0a0a0;height: 28px;">
                  <option
                    v-for="item in MenD"
                    :key="item.id"
                    :label="item.title"
                    :value="item.id">
                  </option>
                </select>
              </div>
            </div>
          </li>
          <li>
            <div class="post-l-li">
              <div class="li-title"></div>
              <div class="li-input">小组
                <input readonly type="text" name="" v-model="this.items.group" style="width: 65%;border: 1px solid #a0a0a0; padding-left: 10px;">
              </div>
            </div>
            <div class="post-l-li">
              <div class="li-title"></div>
              <div class="li-input">小组
                <select v-model="group_id" placeholder="请选择" style="width:75%;border: 1px solid #a0a0a0;height: 28px;">
                  <option
                    v-for="item in Groups"
                    :key="item.id"
                    :label="item.title"
                    :value="item.id">
                  </option>
                </select>
                <el-button @click="upgroup" style="right: 50%;position: relative;margin-top: 35px;width: 60px; height: 35px;">保存</el-button>
              </div>
            </div>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>
<script type="text/babel">
export default {
  props: {
    Refresh: {
      type: Function
    },
    LDmodal: {
      type: Function
    },
    PostClose: {
      type: Function
    },
    Mid: {
      type: Number
    },
    allitems: {
      type: Object
    },
    jobs: {
      type: Array
    }
  },
  data() {
    return {
      Jjob: "",
      Sjob: "",
      Quyu: [],
      department_id: "",
      MenD: [],
      store_id: "",
      Groups: [],
      group_id: ""
    };
  },
  methods: {
    // 获取所有区域
    getQU() {
      let that = this;
      that.$http
        .get("/index/department", {})
        .then(res => {
          that.Quyu = res.data;
        })
        .catch(err => {
          console.log(err);
        });
    },
    //获取门店
    getMen() {
      let that = this;
      that.$http
        .get("/index/department", {
          params: {
            id: that.department_id
          }
        })
        .then(res => {
          // console.log(res)
          that.MenD = res.data;
        })
        .catch(err => {
          console.log(err);
        });
    },
    //获取小组
    getGroup() {
      let that = this;
      that.$http
        .get("/index/department", {
          params: {
            id: that.store_id
          }
        })
        .then(res => {
          that.Groups = res.data;
        })
        .catch(err => {
          console.log(err);
        });
    },
    //升职
    upsubmit() {
      let that = this;
      that.$http
        .post("/index/staff/adjust/set_job", {
          id: that.Pid,
          job_id: that.Sjob
        })
        .then(res => {
          if (res.data.status === 1) {
            that.PostClose();
            that.Refresh();
            that.$store.state.messageString = res.data.msg;
            that.LDmodal();
          } else {
            that.$store.state.messageString = res.data.msg;
            that.LDmodal();
          }
          // console.log(res.data.msg)
        })
        .catch(err => {
          console.log(err);
        });
    },
    //降职
    downsubmit() {
      let that = this;
      that.$http
        .post("/index/staff/adjust/set_job", {
          id: that.Pid,
          job_id: that.Jjob
        })
        .then(res => {
          if (res.data.status === 1) {
            that.PostClose();
            that.$store.state.messageString = res.data.msg;
            that.LDmodal();
          } else {
            that.$store.state.messageString = res.data.msg;
            that.LDmodal();
          }
          // console.log(res.data.msg)
        })
        .catch(err => {
          console.log(err);
        });
    },
    //保存部门
    upgroup() {
      let that = this;
      that.$http
        .post("/index/staff/adjust/set_department", {
          id: that.Pid,
          department_id: that.department_id,
          store_id: that.store_id,
          group_id: that.group_id
        })
        .then(res => {
          if (res.data.status === 1) {
            that.PostClose();
            that.$store.state.messageString = res.data.msg;
            that.LDmodal();
          } else {
            that.$store.state.messageString = res.data.msg;
            that.LDmodal();
          }
        })
        .catch(err => {
          console.log(err);
        });
    }
  },
  computed: {
    Pid() {
      return this.Mid;
    },
    items() {
      return this.allitems;
    },
    Job() {
      return this.jobs;
    }
  },
  created() {
    this.getQU();
  }
};
</script>
<style scoped>
.modal {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
}
.title {
  width: 100%;
  text-align: center;
  margin-bottom: 20px;
  font-weight: bold;
}
.li-input button {
  line-height: 27px;
  background: #1590ed;
  color: #fff;
  border: none;
  margin-left: 10px;
  padding: 0 10px;
  cursor: pointer;
}
.li-title1 {
  font-weight: normal !important;
}
.post-list1 {
  margin-top: 50px;
  border-bottom: none !important;
}
.li-input_box input {
  width: 40%;
  margin-left: 10px;
  line-height: 27px;
  border: 1px solid #d3d3d3;
  cursor: pointer;
  margin-top: 50%;
}
.li-input_box {
  width: 60%;
  display: inline-block;
  font-weight: bold;
}
.li-input input {
  width: 40%;
  margin-left: 10px;
  line-height: 27px;
  border: 1px solid #d3d3d3;
  cursor: pointer;
}
.li-input {
  width: 60%;
  display: inline-block;
  font-weight: bold;
}
.li-title {
  width: 30%;
  text-align: center;
  line-height: 27px;
  display: inline-block;
  font-weight: bold;
}
.li-title_box {
  width: 30%;
  text-align: center;
  line-height: 27px;
  display: inline-block;
  font-weight: bold;
  margin-top: 30%;
}
.post-l-li {
  width: 50%;
  float: left;
}
.post-list {
  width: 100%;
  float: left;
  border-bottom: 5px solid #f9f9f9;
}
.post-list li {
  margin-bottom: 20px;
  width: 95%;
  padding-left: 5%;
  float: left;
}
.post-title {
  text-align: center;
  width: 100%;
  float: left;
  right: 93px;
  position: relative;
  margin: 30px 0;
  font-weight: bold;
}
.post-title input {
  width: 20%;
  margin-left: 10px;
  border: 1px solid #d3d3d3;
  line-height: 27px;
  cursor: pointer;
}
.li-input .el-select {
  width: 50% !important;
}
.post {
  width: 40%;
  background: #fff;
  position: absolute;
  z-index: 10;
  top: 60%;
  left: 30%;
  border-radius: 5px;
  overflow: hidden;
  height: 420px;
  overflow-y: auto;
  padding-bottom: 20px;
  margin-top: -250px;
}
img:hover {
  background: #bd2c00 !important;
  color: #ffffff;
}

img {
  /*position: fixed;*/
  /* flex-star:40px; */
  /*margin-left: 44%;*/
  /* position: relative; */
  cursor: pointer;
  border-radius: 10px;
}
img {
  left: 116%;
}
.rele-titles {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  width: 100%;
  line-height: 50px;
  font-size: 2em;
  color: #000;
  background: #f5f5f7;
  position: absolute;
  z-index: 9;
  border-bottom: 1px solid #d3d3d3;
}

.box_button {
  margin-top: 20px;
}
select {
  cursor: pointer;
}
.button_box {
  right: 30%;
  position: relative;
  top: 30px;
}
</style>
